package lesson02;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class JButtonDemo extends JFrame {
    public static void main(String[] args) {
        new JButtonDemo();
    }
    public JButtonDemo(){
        Container container = this.getContentPane();
        //把一个图片变成按钮
        URL url = JButtonDemo.class.getResource("tx.jpg");
        ImageIcon icon = new ImageIcon(url);
        //把图片放在按钮上
        JButton button = new JButton();
        button.setIcon(icon);
        button.setToolTipText("图片按钮");
        //单选框
//        JRadioButton jRadioButton1 = new JRadioButton("JRadioButton1");
//        JRadioButton jRadioButton2 = new JRadioButton("JRadioButton2");
//        JRadioButton jRadioButton3 = new JRadioButton("JRadioButton3");
//        //通过分组的概念来实现单选的效果
//        ButtonGroup buttonGroup = new ButtonGroup();
//        buttonGroup.add(jRadioButton1);
//        buttonGroup.add(jRadioButton2);
//        buttonGroup.add(jRadioButton3);
//        container.add(jRadioButton1,BorderLayout.CENTER);
//        container.add(jRadioButton2,BorderLayout.SOUTH);
//        container.add(jRadioButton3,BorderLayout.NORTH);
        //add
        JCheckBox jCheckBox1 = new JCheckBox("JCheckBox1");
        JCheckBox jCheckBox2 = new JCheckBox("JCheckBox2");
        container.add(jCheckBox1,BorderLayout.CENTER);
        container.add(jCheckBox2,BorderLayout.SOUTH);
//        container.add(button);
        this.setVisible(true);
        this.setSize(500,500);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}
